﻿namespace HRM.CORE
{
    using APP.HELPER.Data.Helper;
    using APP.HELPER.Utils.CustomizeToolbox;
    using DevExpress.XtraEditors;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms; using Common;

    public class HRM_PAYINSURANCE_TABLELIST
    {
        private int m_Month;
        private int m_NumberEmployee;
        private int m_NumberEmployeeFemale;
        private Guid m_PayInsuranceTableListID;
        private string m_PayInsuranceTableListName;
        private int m_Quarter;
        private decimal m_Wage;
        private int m_Year;

        public HRM_PAYINSURANCE_TABLELIST()
        {
            this.m_PayInsuranceTableListID = Guid.Empty;
            this.m_PayInsuranceTableListName = "";
            this.m_Month = 0;
            this.m_Quarter = 0;
            this.m_Year = 0;
            this.m_NumberEmployee = 0;
            this.m_NumberEmployeeFemale = 0;
            this.m_Wage = 0M;
        }

        public HRM_PAYINSURANCE_TABLELIST(Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            this.m_PayInsuranceTableListID = PayInsuranceTableListID;
            this.m_PayInsuranceTableListName = PayInsuranceTableListName;
            this.m_Month = Month;
            this.m_Quarter = Quarter;
            this.m_Year = Year;
            this.m_NumberEmployee = NumberEmployee;
            this.m_NumberEmployeeFemale = NumberEmployeeFemale;
            this.m_Wage = Wage;
        }

        public void AddCombo(System.Windows.Forms.ComboBox combo)
        {
            GridCalendarControlLib.TableToComboBox(combo, this.GetList(), "InsuranceTableListName", "InsuranceTableListID");
        }

        public void AddComboAll(System.Windows.Forms.ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["PayInsuranceTableListID"] = "All";
            row["PayInsuranceTableListName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            GridCalendarControlLib.TableToComboBox(combo, list, "PayInsuranceTableListName", "PayInsuranceTableListID");
        }

        public void AddComboEdit(ComboBoxEdit combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            foreach (DataRow row in list.Rows)
            {
                combo.Properties.Items.Add(row["PayInsuranceTableListName"]);
            }
        }

        public void AddGridLookupEdit(GridLookUpEdit gridlookup)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            gridlookup.Properties.DataSource = list;
            gridlookup.Properties.DisplayMember = "PayInsuranceTableListName";
            gridlookup.Properties.ValueMember = "PayInsuranceTableListID";
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { this.m_PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Delete", myParams, myValues);
        }

        public string Delete(string PayInsuranceTableListID)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string PayInsuranceTableListID)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PAYINSURANCE_TABLELIST_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string PayInsuranceTableListID)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PAYINSURANCE_TABLELIST_Delete", myParams, myValues);
        }

        public bool Exist(string PayInsuranceTableListID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PAYINSURANCE_TABLELIST_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid PayInsuranceTableListID)
        {
            string str = "";
            string[] myParams = new string[] { "@PayInsuranceTableListID" };
            object[] myValues = new object[] { PayInsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PAYINSURANCE_TABLELIST_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PayInsuranceTableListID = reader.GetGuid(reader.GetOrdinal("PayInsuranceTableListID"));
                    this.m_PayInsuranceTableListName = Convert.ToString(reader["PayInsuranceTableListName"]);
                    this.m_Month = Convert.ToInt32(reader["Month"]);
                    this.m_Quarter = Convert.ToInt32(reader["Quarter"]);
                    this.m_Year = Convert.ToInt32(reader["Year"]);
                    this.m_NumberEmployee = Convert.ToInt32(reader["NumberEmployee"]);
                    this.m_NumberEmployeeFemale = Convert.ToInt32(reader["NumberEmployeeFemale"]);
                    this.m_Wage = Convert.ToDecimal(reader["Wage"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid InsuranceTableListID)
        {
            string str = "";
            string[] myParams = new string[] { "@InsuranceTableListID" };
            object[] myValues = new object[] { InsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PAYINSURANCE_TABLELIST_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PayInsuranceTableListID = reader.GetGuid(reader.GetOrdinal("PayInsuranceTableListID"));
                    this.m_PayInsuranceTableListName = Convert.ToString(reader["PayInsuranceTableListName"]);
                    this.m_Month = Convert.ToInt32(reader["Month"]);
                    this.m_Quarter = Convert.ToInt32(reader["Quarter"]);
                    this.m_Year = Convert.ToInt32(reader["Year"]);
                    this.m_NumberEmployee = Convert.ToInt32(reader["NumberEmployee"]);
                    this.m_NumberEmployeeFemale = Convert.ToInt32(reader["NumberEmployeeFemale"]);
                    this.m_Wage = Convert.ToDecimal(reader["Wage"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid InsuranceTableListID)
        {
            string str = "";
            string[] myParams = new string[] { "@InsuranceTableListID" };
            object[] myValues = new object[] { InsuranceTableListID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PAYINSURANCE_TABLELIST_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PayInsuranceTableListID = reader.GetGuid(reader.GetOrdinal("PayInsuranceTableListID"));
                    this.m_PayInsuranceTableListName = Convert.ToString(reader["PayInsuranceTableListName"]);
                    this.m_Month = Convert.ToInt32(reader["Month"]);
                    this.m_Quarter = Convert.ToInt32(reader["Quarter"]);
                    this.m_Year = Convert.ToInt32(reader["Year"]);
                    this.m_NumberEmployee = Convert.ToInt32(reader["NumberEmployee"]);
                    this.m_NumberEmployeeFemale = Convert.ToInt32(reader["NumberEmployeeFemale"]);
                    this.m_Wage = Convert.ToDecimal(reader["Wage"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PAYINSURANCE_TABLELIST_GetList");
        }

        public DataTable GetListByYear(int Year)
        {
            string[] myParams = new string[] { "@Year" };
            object[] myValues = new object[] { Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PAYINSURANCE_TABLELIST_GetListByYear", myParams, myValues);
        }

        public DataTable GetProcessList(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PAYINSURANCE_TABLELIST_GetProcessList", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { this.m_PayInsuranceTableListID, this.m_PayInsuranceTableListName, this.m_Month, this.m_Quarter, this.m_Year, this.m_NumberEmployee, this.m_NumberEmployeeFemale, this.m_Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { this.m_PayInsuranceTableListID, this.m_PayInsuranceTableListName, this.m_Month, this.m_Quarter, this.m_Year, this.m_NumberEmployee, this.m_NumberEmployeeFemale, this.m_Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PAYINSURANCE_TABLELIST_Insert", myParams, myValues);
        }

        public string Insert(Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PAYINSURANCE_TABLELIST_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PAYINSURANCE_TABLELIST_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PAYINSURANCE_TABLELIST", "InsuranceTableListID", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { this.m_PayInsuranceTableListID, this.m_PayInsuranceTableListName, this.m_Month, this.m_Quarter, this.m_Year, this.m_NumberEmployee, this.m_NumberEmployeeFemale, this.m_Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Update", myParams, myValues);
        }

        public string Update(Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PAYINSURANCE_TABLELIST_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PAYINSURANCE_TABLELIST_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid PayInsuranceTableListID, string PayInsuranceTableListName, int Month, int Quarter, int Year, int NumberEmployee, int NumberEmployeeFemale, decimal Wage)
        {
            string[] myParams = new string[] { "@PayInsuranceTableListID", "@PayInsuranceTableListName", "@Month", "@Quarter", "@Year", "@NumberEmployee", "@NumberEmployeeFemale", "@Wage" };
            object[] myValues = new object[] { PayInsuranceTableListID, PayInsuranceTableListName, Month, Quarter, Year, NumberEmployee, NumberEmployeeFemale, Wage };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PAYINSURANCE_TABLELIST_Update", myParams, myValues);
        }

        [DisplayName("Month"), Category("Column")]
        public int Month
        {
            get
            {
                return this.m_Month;
            }
            set
            {
                this.m_Month = value;
            }
        }

        [Category("Column"), DisplayName("NumberEmployee")]
        public int NumberEmployee
        {
            get
            {
                return this.m_NumberEmployee;
            }
            set
            {
                this.m_NumberEmployee = value;
            }
        }

        [Category("Column"), DisplayName("NumberEmployeeFemale")]
        public int NumberEmployeeFemale
        {
            get
            {
                return this.m_NumberEmployeeFemale;
            }
            set
            {
                this.m_NumberEmployeeFemale = value;
            }
        }

        [DisplayName("PayInsuranceTableListID"), Category("Primary Key")]
        public Guid PayInsuranceTableListID
        {
            get
            {
                return this.m_PayInsuranceTableListID;
            }
            set
            {
                this.m_PayInsuranceTableListID = value;
            }
        }

        [Category("Column"), DisplayName("PayInsuranceTableListName")]
        public string PayInsuranceTableListName
        {
            get
            {
                return this.m_PayInsuranceTableListName;
            }
            set
            {
                this.m_PayInsuranceTableListName = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PAYINSURANCE_TABLELIST";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Quarter")]
        public int Quarter
        {
            get
            {
                return this.m_Quarter;
            }
            set
            {
                this.m_Quarter = value;
            }
        }

        [DisplayName("Wage"), Category("Column")]
        public decimal Wage
        {
            get
            {
                return this.m_Wage;
            }
            set
            {
                this.m_Wage = value;
            }
        }

        [Category("Column"), DisplayName("Year")]
        public int Year
        {
            get
            {
                return this.m_Year;
            }
            set
            {
                this.m_Year = value;
            }
        }
    }
}

